<template>
    <!-- 玄幻小说展示页面 -->
    <div class="content">
        <ul>
            <li v-for="item in storList" :key="item.id">
                <div>
                    <router-link :to="{ name: 'info', query: item }">
                        <img :src="item.imgUrl" alt="" />
                    </router-link>
                </div>
                <div class="messageBox">
                    <router-link class="title" :to="{ name: 'info', query: item }">
                        {{ item.title }}
                    </router-link>
                    <p>{{ item.passage }}</p>
                    <span>作者:{{ item.author }}</span>
                    <span>{{ item.sort }}</span>
                </div>
            </li>
        </ul>
    </div>
</template>

<style scoped>
.content {
    max-width: 1240px;
    margin: 0 auto;
}

.content ul {
    width: 100%;
    display: flex;
    margin: 40px auto;
    justify-content: space-around;
    flex-wrap: wrap;
}

.content ul li {
    display: flex;
    flex: 0 0 30%;
    height: 180px;
    justify-content: center;
    align-items: center;
    border: 1px solid #ccc;
    margin-bottom: 20px;
}

.content ul li div:nth-child(1) {
    flex: 0 0 40%;
    overflow: hidden;
    height: 150px;
}

.content ul li div:nth-child(1) img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.content ul li div:nth-child(1) img:hover {
    transform: scale(1.1);
    transition: all 0.5s ease-out;
}

.content ul li .messageBox {
    font-size: 14px;
    flex: 0 0 50%;
    position: relative;
    height: 150px;
}

.content ul li .messageBox .title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    font-size: 20px;
    font-weight: 600;
}

.content ul li .messageBox .title:hover {
    color: red;
}

.content ul li .messageBox p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    margin: 10px 0px;
    overflow: hidden;
}

.content ul li .messageBox span {
    display: inline-block;
    position: absolute;
    bottom: 0;
}

.content ul li .messageBox span:nth-child(4) {
    right: 0;
    color: #ccc;
    border: 1px solid #ccc;
}
</style>

<script setup>
import axios from 'axios'
import { ref } from 'vue';
import { RouterLink } from "vue-router"
const storList = ref([])
const storget = axios.create({
    baseURL: 'http://localhost:8000',
    timeout: 5000
})
storget.get('/index').then((req) => {
    storList.value = req.data
})

</script>



